#include "databasemanager.h"

#include <QSqlDatabase>

DatabaseManager &DatabaseManager::instance()
{
    static DatabaseManager singleton;
    return singleton;
}

DatabaseManager::~DatabaseManager()
{
    m_database->close();
    delete m_database;
}

DatabaseManager::DatabaseManager(const QString &path):
    m_database(new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"))),
    m_album_dao(*m_database),
    m_picture_dao(*m_database)
{
    m_database->setDatabaseName(path);
    m_database->open();

    m_album_dao.init();
    m_picture_dao.init();
}
